Allow netback to be built as a module.
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 28 Feb 2006 17:59:24 +0000 (18:59 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 28 Feb 2006 17:59:24 +0000 (18:59 +0100)
From: Jan Beulich

Signed-off-by: Keir Fraser <keir@xensource.com>
buildconfigs/linux-defconfig_xen0_x86_32
buildconfigs/linux-defconfig_xen0_x86_64
buildconfigs/linux-defconfig_xen_x86_32
buildconfigs/linux-defconfig_xen_x86_64
linux-2.6-xen-sparse/drivers/xen/Kconfig
linux-2.6-xen-sparse/drivers/xen/core/skbuff.c
linux-2.6-xen-sparse/drivers/xen/netback/Makefile
linux-2.6-xen-sparse/drivers/xen/netback/loopback.c
linux-2.6-xen-sparse/drivers/xen/netback/netback.c

index f9138569bfc7e9395d7ab4906801bdc4bae54a95..f3ea4053b5e2b76d6a1a8b4a7f2d7d761ca91b6b 100644 (file)
@@ -1320,6 +1320,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
 # CONFIG_XEN_BLKDEV_TAP_BE is not set
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=y
 # CONFIG_XEN_TPMDEV_BACKEND is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
index e6563cb32ba22812172169e64c913e3439e1a218..7baeb3d47e89e1f7ad298eed51c9ed7ab8b5449a 100644 (file)
@@ -1244,6 +1244,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
 # CONFIG_XEN_BLKDEV_TAP_BE is not set
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=y
 # CONFIG_XEN_TPMDEV_BACKEND is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
index db03a3a82a37f72cabb81934b7f8a7dc299d4832..49208186f92b20d4bdcaf5a5e6a20138caac848c 100644 (file)
@@ -2986,6 +2986,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
 # CONFIG_XEN_BLKDEV_TAP_BE is not set
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=y
 # CONFIG_XEN_TPMDEV_BACKEND is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
index 0f70c8a940b32dcf9a38d9653b1505351b0fd1c0..85314f98d3e7f9c0ed52551f9dba45d46b9803ba 100644 (file)
@@ -2656,6 +2656,7 @@ CONFIG_XEN_BLKDEV_BACKEND=y
 # CONFIG_XEN_BLKDEV_TAP_BE is not set
 CONFIG_XEN_NETDEV_BACKEND=y
 # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
+CONFIG_XEN_NETDEV_LOOPBACK=y
 # CONFIG_XEN_TPMDEV_BACKEND is not set
 CONFIG_XEN_BLKDEV_FRONTEND=y
 CONFIG_XEN_NETDEV_FRONTEND=y
index 046de51a217bdb71826a047ba6c404d87d725979..2cd2d937ead929355a1dd204dcb80a3b30d8eb11 100644 (file)
@@ -89,7 +89,7 @@ config XEN_BLKDEV_TAP_BE
           modified to use grant tables.
 
 config XEN_NETDEV_BACKEND
-       bool "Network-device backend driver"
+       tristate "Network-device backend driver"
        default y
        help
          The network-device backend driver allows the kernel to export its
@@ -109,6 +109,14 @@ config XEN_NETDEV_PIPELINED_TRANSMITTER
          are unsure; or if you experience network hangs when this option is
          enabled; then you must say N here.
 
+config XEN_NETDEV_LOOPBACK
+       tristate "Network-device loopback driver"
+       depends on XEN_NETDEV_BACKEND
+       default y
+       help
+         A two-interface loopback device to emulate a local netfront-netback
+         connection.
+
 config XEN_TPMDEV_BACKEND
        bool "TPM-device backend driver"
        default n
index c90fc20b5608e506e141b2fa28a20df08329f4b3..c12362ded722263e54f389dff7f721c7193fafc4 100644 (file)
@@ -16,6 +16,7 @@
 
 /* Referenced in netback.c. */
 /*static*/ kmem_cache_t *skbuff_cachep;
+EXPORT_SYMBOL(skbuff_cachep);
 
 #define MAX_SKBUFF_ORDER 4
 static kmem_cache_t *skbuff_order_cachep[MAX_SKBUFF_ORDER + 1];
index fd75bff6aba785b28a3c01a51735b503faae71c3..d5d232837ee49311753ab43963e087d7300fd6df 100644 (file)
@@ -1,2 +1,5 @@
+obj-$(CONFIG_XEN_NETDEV_BACKEND) := netbk.o
+obj-$(CONFIG_XEN_NETDEV_LOOPBACK) += netloop.o
 
-obj-y  := netback.o xenbus.o interface.o loopback.o
+netbk-y   := netback.o xenbus.o interface.o
+netloop-y := loopback.o
index 03e6c2972998dd29e54ac659d8ebcbc5ebd1f3c9..a5a11cc55e5cc36b91175879e20b73be68600eab 100644 (file)
@@ -178,6 +178,23 @@ static int __init make_loopback(int i)
        return err;
 }
 
+static void __init clean_loopback(int i)
+{
+       struct net_device *dev1, *dev2;
+       char dev_name[IFNAMSIZ];
+
+       sprintf(dev_name, "vif0.%d", i);
+       dev1 = dev_get_by_name(dev_name);
+       sprintf(dev_name, "veth%d", i);
+       dev2 = dev_get_by_name(dev_name);
+       if (dev1 && dev2) {
+               unregister_netdev(dev2);
+               unregister_netdev(dev1);
+               free_netdev(dev2);
+               free_netdev(dev1);
+       }
+}
+
 static int __init loopback_init(void)
 {
        int i, err = 0;
@@ -191,6 +208,18 @@ static int __init loopback_init(void)
 
 module_init(loopback_init);
 
+static void __exit loopback_exit(void)
+{
+       int i;
+
+       for (i = nloopbacks; i-- > 0; )
+               clean_loopback(i);
+}
+
+module_exit(loopback_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+
 /*
  * Local variables:
  *  c-file-style: "linux"
index 3b6de4612d22ecc1363c8766c24c39415300ac8e..64173fae5d0e859947b22e7dcb8c6a81d6f94ef3 100644 (file)
@@ -809,6 +809,8 @@ static int __init netback_init(void)
                &netif_be_dbg);
 #endif
 
+       __unsafe(THIS_MODULE);
+
        return 0;
 }
 
@@ -820,6 +822,8 @@ static void netback_cleanup(void)
 module_init(netback_init);
 module_exit(netback_cleanup);
 
+MODULE_LICENSE("Dual BSD/GPL");
+
 /*
  * Local variables:
  *  c-file-style: "linux"